% /*******************************************************************************
%  * Binary Conversion
%  * *****************************************************************************
%  * Print out the number as binary format to file
%  * 
%  * @param x             Input Number in [0,1)
%  * @param bits_to_left  
%  * @param bits_to_right 
%  * @param out_file      File to write out
%  */
function disp_bin(x, bits_to_left, bits_to_right, fid)
if(abs(x) < 2^(-bits_to_right))
    for i = -bits_to_left + 1 : bits_to_right
        fprintf(fid,'0');
    end
    return
end
if(x < 0.0)
    x = 2^bits_to_left + x;
end
for i = -bits_to_left + 1 : bits_to_right
    diff = 2^-i;
    if(x < diff)
        fprintf(fid,'0');
    else
        fprintf(fid,'1');
        x = x - diff;
    end
    if(i==0)
        fprintf(fid,'.');
    end
end
end